use std::{collections::HashMap, pin::Pin};

use axum::{
    http::{header, HeaderMap, StatusCode},
    response::IntoResponse,
};
use futures::Future;
use serde_json::json;

trait Request: Send + 'static {}

struct Req1;
impl Request for Req1 {}
struct Resp1;
impl IntoResponse for Resp1 {
    fn into_response(self) -> axum::response::Response {
        "".to_string().into_response()
    }
}

struct Req2;
impl Request for Req2 {}
struct Resp2;
impl IntoResponse for Resp2 {
    fn into_response(self) -> axum::response::Response {
        let mut headers = HeaderMap::new();
        headers.insert(header::CONTENT_TYPE, "text/plain".parse().unwrap());
        (headers, "foo").into_response()
    }
}

trait Service {
    fn my_async_function(&self) -> Box<dyn Future<Output = String>>;
}

struct S1;
impl Service for S1 {
    fn my_async_function(&self) -> Box<dyn Future<Output = String>> {
        Box::new(async { "".to_string() })
    }
}

struct S2;
impl Service for S2 {
    fn my_async_function(&self) -> Box<dyn Future<Output = String>> {
        Box::new(async { "23444".to_string() })
    }
}

async fn f1(req: Box<dyn Request>) -> impl IntoResponse {
    Resp1 {}
}

#[tokio::test]
async fn test1() {
    let f = f1(Box::new(Req1 {}));
    // let mut map = HashMap::new();
    // map.insert("f1", Box::new(|p|Box::pin(f1(p))));
    // map.insert("f2", Box::new(|p|Box::pin(f2(p))));
    // map.insert("f2", f2);
}
